<script setup lang="ts">
import { onMounted,ref } from "vue";
import {getArticleList} from "@/api/article.js"
import ArchiveContent from "./components/ArchiveContent.vue";
let articles = ref([]);
onMounted(()=>{
  getArticles();
})

const getArticles = async(typeId)=>{
  const requestObj = {page:1,size:30};
  if(typeId) {
    requestObj.typeId = typeId;
  }
  const res = await getArticleList(requestObj);
  res.data.sort((a,b)=>{
    return parseInt(b.createTime)-parseInt(a.createTime);
  })
  articles.value = res.data;
  console.log(articles,"list")
}

const handleChangeCate = (enumCode)=>{
    getArticles(enumCode)
}

</script>

<template>
  <ArchiveContent type="cate-type" :list="articles" @IdChange="handleChangeCate"/>
</template>

<style scoped lang="scss"></style>
